<?php

namespace Common\Model;

/**
 * 订单查房变化记录表
 * @modify wenhui 2018-02-27 创建
 * @index orderrecord_id (`orderrecord_id`)
 */
Class OrderRoomCheckRecordModel extends \Common\Model\BaseModel {

    protected $trueTableName = 'tb_order_room_check_record';

    protected function _before_insert(&$data, $options) {
        // parent::_before_insert($data, $options);
    }

    protected function _before_update(&$data, $options) {
        
    }

    /**
     * 添加一条或多条记录
     * @modify wenhui 2018-02-27 创建
     * @param  array   $infoArray 信息数组,每个记录必须包含的信息有id,
     * @return mixin              执行成功返回最后一个添加条目id
     */
    public function addInfo($infoArray) {
        return $this->addAll($infoArray) === false ? false : true;
    }

    /**
     * 根据父订单修改记录取数据
     * @modify trainyao 2016-01-05     创建
     * @param  mixin   $orderRecordId 父订单修改记录id(s)
     * @return array                  修改记录数组
     */
    public function getInfoByOrderRecord($orderRecordId) {
        $option = array();
        if (is_array($orderRecordId)) {
            $orderRecordId = implode(',', $orderRecordId);
        }

        if (strpos($orderRecordId, ',') !== false) {
            $option['orderrecord_id'] = array('in', $orderRecordId);
        } else {
            $option['orderrecord_id'] = $orderRecordId;
        }
        $data = $this->where($option)->select();

        return empty($data) ? array() : $data;
    }

}
